import wx
from Sound import Sound
from Constant import *
from Frame_Main import Frame_Main
import sys 
reload(sys) 
sys.setdefaultencoding('cp950') 
'''
Main : 
    The main frame of this game.
'''
class Main(wx.Frame):
    '''
    Constructor : Main
    '''
    def __init__(self):
        size = (800, 650)
        wx.Frame.__init__(self, None, -1, size = size, pos = (50,50), title = "Diamond game",
                     style = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX)
        self.ACT002_setSize(size)
        self._001_initialInstanceVariable()
        self._002_createSoundObj()
    '''
    function _001 : initialize the variables used for this object
    '''
    def _001_initialInstanceVariable(self):
        self.sound = None
    '''
    function _002 : create object of class - Sound
    '''
    def _002_createSoundObj(self):
        self.sound = Sound()
        #load sound effect
        self.sound.ACT003_loadSound(DIR_SOUND + "/burst.wav", SOUND_BURST)
        self.sound.ACT003_loadSound(DIR_SOUND + "/water.wav", SOUND_WATER)
        self.sound.ACT003_loadSound(DIR_SOUND + "/enter.wav", SOUND_ENTER)
        self.sound.ACT003_loadSound(DIR_SOUND + "/select.wav", SOUND_SELECT)
        self.sound.ACT003_loadSound(DIR_SOUND + "/burp.wav", SOUND_BURP)
        self.sound.ACT003_loadSound(DIR_SOUND + "/pushBtn.wav", SOUND_PUSH_BUTTON)
        #load music
        self.sound.ACT004_loadBackgroundMusic(DIR_SOUND + "/background main.ogg", 0)
        self.sound.ACT004_loadBackgroundMusic(DIR_SOUND + "/background music1.ogg", 1)
        self.sound.ACT004_loadBackgroundMusic(DIR_SOUND + "/background music2.ogg", 2)
        self.sound.ACT004_loadBackgroundMusic(DIR_SOUND + "/background music3.ogg", 3)
        self.sound.ACT004_loadBackgroundMusic(DIR_SOUND + "/background music4.ogg", 4)
    '''
    function ACT001 : play effect sound according the passing name
    '''
    def ACT001_playSound(self, name):
        self.sound.ACT002_playSound(name)
        pass
    '''
    function ACT002 : set size of this frame
    '''
    def ACT002_setSize(self, size):
        self.SetSize(size)
    '''
    function ACT003 : play background music
    '''
    def ACT003_playBackgroundMusic(self, name):
        self.sound.ACT001_playBackgroundMusic(name)
        pass
'''
main program
'''
if __name__ == "__main__" :
    app = wx.PySimpleApp()
    frame = Main()
    Frame_Main(frame)
    frame.Show()
    app.MainLoop()